home *** CD-ROM | disk | FTP | other *** search
/ AOL File Library: 2,801 to 2,900 / aol-file-protocol-4400-2801-to-2900.zip / AOLDLs / C++ Files Library / HyperCuber Source / HyperCuber 2.0 Source.sit / HyperCuber 2.0 Source / CPrefsDialog.cp < prev    next >
Text File  |  1994-05-02  |  4KB  |  127 lines

  1. //|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2. //| CPrefsDialog.cp
  3. //|
  4. //| This implements the preferences dialog
  5. //|_________________________________________________________
  6.  
  7. #include "CPrefsDialog.h"
  8. #include "CColorPane.h"
  9. #include "CHyperCuberDoc.h"
  10. #include "CHyperCuberPrefs.h"
  11. #include "CPrefsDialogDirector.h"
  12.  
  13. #include "HyperCuber Balloons.h"
  14. #include "HyperCuber Commands.h"
  15.  
  16. #include <CButton.h>
  17. #include <CDecorator.h>
  18. #include <CEditText.h>
  19. #include <CPaneBorder.h>
  20.  
  21. #include <string.h>
  22.  
  23. extern CDecorator         *gDecorator;
  24. extern CHyperCuberPrefs    *gPrefs;
  25.  
  26.  
  27.  
  28. //|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  29. //| CPrefsDialog::IPrefsDialog
  30. //|
  31. //| Purpose: Initialize the preferences dialog.
  32. //|
  33. //| Parameters: WindowID:   ID of WIND resource to use
  34. //|             enclosure:  the Desktop
  35. //|             supervisor: the supervisor of this DialogDirector
  36. //|             doc:        the document (used to get the prefs)
  37. //|______________________________________________________________________________
  38.  
  39. void CPrefsDialog::IPrefsDialog(short WindowID, CDesktop *enclosure, CDirector *supervisor)
  40. {
  41.  
  42.     CButton        *button;
  43.     
  44. #define OKAY_BUTTON_ID        130
  45. #define CANCEL_BUTTON_ID    131
  46. #define DEFAULTS_BUTTON_ID    132
  47.  
  48.     CDialog::IDialog(WindowID, enclosure, supervisor);    //  Initialize window from WIND resource
  49.  
  50.     helpResID = WINDOW_HELP_RES;                    //  Link in the Balloon Help
  51.  
  52.     button = new(CButton);                            //  Set up the okay button
  53.     button->IButton(OKAY_BUTTON_ID, this, this);
  54.     button->Offset(210, 15, TRUE);
  55.     button->SetClickCmd (cmdOK);
  56.     button->helpResIndex = kColorsOkay;
  57.     SetDefaultButton(button);
  58.     
  59.     button = new (CButton);                            //  Set up the cancel button
  60.     button->IButton(CANCEL_BUTTON_ID, this, this);
  61.     button->Offset(210, 50, TRUE);
  62.     button->SetClickCmd (cmdCancel);
  63.     button->helpResIndex = kColorsCancel;
  64.     
  65.     button = new (CButton);                            //  Set up the defaults button
  66.     button->IButton(DEFAULTS_BUTTON_ID, this, this);
  67.     button->Offset(210, 85, TRUE);
  68.     button->SetClickCmd (cmdDefaults);
  69.     button->helpResIndex = kColorsDefault;
  70.     
  71.     InstallColorEntry(&background_color_pane, 10,    //  Set up the colored squares in the dialog
  72.                         "Background Color:",    
  73.                         &(gPrefs->prefs.background_color),
  74.                         kColorsBackground);
  75.     InstallColorEntry(&left_eye_color_pane, 40,
  76.                         "Left Eye Color:",
  77.                         &(gPrefs->prefs.left_eye_color),
  78.                         kColorsLeftEye);
  79.     InstallColorEntry(&right_eye_color_pane, 70,
  80.                         "Right Eye Color:",
  81.                         &(gPrefs->prefs.right_eye_color),
  82.                         kColorsRightEye);
  83.     
  84.     gDecorator->CenterWindow (this);                //  Center the window on the screen
  85.  
  86. }    //=== CPrefsDialog::IPrefsDialog() ===\\
  87.  
  88.  
  89.  
  90. //|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  91. //| CPrefsDialog::InstallColorEntry
  92. //|
  93. //| Purpose: Initialize the preferences dialog.
  94. //|
  95. //| Parameters: color_pane: handle which receives newly-created CColorPane
  96. //|             vert:       vertical position of the pane
  97. //|             color_name: string to put to left of pane
  98. //|             color:      color of pane
  99. //|             help_res:   resource for Balloon Help
  100. //|________________________________________________________________________
  101.  
  102. void CPrefsDialog::InstallColorEntry(CColorPane **color_pane, short vert, char *color_name,
  103.                                         RGBColor *color, short help_res)
  104. {
  105.  
  106.     CEditText *text = new(CEditText);                        //  Set up the color name pane
  107.     text->IEditText(this, this, 150, 20,
  108.                     10, vert + 2, sizFIXEDLEFT, sizFIXEDTOP, -1);
  109.     text->SetTextPtr(color_name, strlen(color_name));
  110.     text->SetFontNumber(systemFont);
  111.     text->SetFontSize(12);
  112.     text->SetWantsClicks(FALSE);
  113.     text->Specify(kNotEditable, kNotSelectable, kNotStylable);
  114.     
  115.     *color_pane = new(CColorPane);                            //  Set up the colored pane
  116.     (*color_pane)->IColorPane(this, this, 20, 20,
  117.                             150, vert, sizFIXEDLEFT, sizFIXEDTOP, color);
  118.     (*color_pane)->SetWantsClicks(TRUE);
  119.     (*color_pane)->helpResIndex = help_res;
  120.  
  121.     CPaneBorder *border = new(CPaneBorder);                    //  Border the color name pane
  122.     border->IPaneBorder(kBorderFrame);
  123.     border->SetPenSize(2, 2);
  124.     (*color_pane)->SetBorder(border);
  125.  
  126. }    //==== CPrefsDialog::InstallColorEntry() ====\\
  127.